{% extends "dashboard/base.html" %}
{% load i18n %}
{% load prices_i18n %}

{% block title %}
  {{ block.super }}
{% endblock %}

{% block content %}
  <div class="row">
    <div class="col s12">
      <div class="card">
        <div class="data-table-header{% if not preauthorized_payments %} data-table-header--no-data{% endif %}">
          <span class="data-table-title">
            {% trans "Preauthorized payments" context "Dashboard homepage table title" %}
          </span>
        </div>
        {% if preauthorized_payments %}
          <div class="data-table-container">
            <table class="bordered highlight responsive data-table">
              <thead>
                <tr>
                  <th>
                    {% trans "Order" context "Preauthorized payments table header" %}
                  </th>
                  <th>
                    {% trans "Date" context "Preauthorized payments table header" %}
                  </th>
                  <th>
                    {% trans "Customer" context "Preauthorized payments table header" %}
                  </th>
                  <th class="right-align">
                    {% trans "Amount" context "Preauthorized payments table header" %}
                  </th>
                </tr>
              </thead>
              <tbody>
                {% for payment in preauthorized_payments %}
                  <tr data-action-go="{% url "dashboard:order-details" order_pk=payment.order.pk %}">
                    <td>
                      {{ payment.order }}
                    </td>
                    <td>
                      {{ payment.created }}
                    </td>
                    <td>
                      {{ payment.order.user|default:_("Guest") }}
                    </td>
                    <td class="right-align">
                      {% gross payment.get_total_price html=True %}
                    </td>
                  </tr>
                {% endfor %}
              </tbody>
            </table>
          </div>
        {% else %}
          <div class="card-content card-content--no-data not-found">
            <p class="grey-text">
              {% trans "No preauthorized payments." context "Empty Preauthorized payments table message" %}
            </p>
          </div>
        {% endif %}
      </div>

      <div class="card">
        <div class="data-table-header{% if not orders_to_ship %} data-table-header--no-data{% endif %}">
          <span class="data-table-title">
            {% trans "Orders ready for shipment" context "Dashboard homepage table title" %}
          </span>
        </div>
        {% if orders_to_ship %}
          {% include "dashboard/includes/_orders_table.html" with orders=orders_to_ship %}
        {% else %}
          <div class="card-content card-content--no-data not-found ">
            <p class="grey-text">
              {% trans "No orders are ready for shipment." context "Empty order table message" %}
            </p>
          </div>
        {% endif %}
      </div>
      <div class="card">
        <div class="data-table-header{% if not preauthorized_payments %} data-table-header--no-data{% endif %}">
          <span class="data-table-title">
            {% trans "Products with low stock" context "Dashboard homepage table title" %}
          </span>
        </div>
        {% if low_stock %}
          <div class="data-table-container">
            <table class="bordered highlight responsive data-table">
              <thead>
                <tr>
                  <th>
                    {% trans "Product name" context "Low stock product list" %}
                  </th>
                  <th class="right-align">
                    {% trans "Stock left" context "Low stock product list" %}
                  </th>
                </tr>
              </thead>
              <tbody>
                {% for product in low_stock %}
                  <tr data-action-go="{% url "dashboard:product-update" pk=product.pk %}#stock">
                    <td>
                      {{ product }}
                    </td>
                    <td class="right-align">
                      {{ product.total_stock }}
                    </td>
                  </tr>
                {% endfor %}
              </tbody>
            </table>
          </div>
        {% else %}
          <div class="card-content card-content--no-data not-found">
            <p class="grey-text">
              {% trans "No products are low in stock." context "Empty low stock table message" %}
            </p>
          </div>
        {% endif %}
      </div>
    </div>
  </div>
{% endblock %}
